package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import entity.User;
import service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User login(String username, String password) {
        return userDao.findByUsernameAndPassword(username,password);
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public User findOne(int id) {
        return userDao.findById(id);
    }

    @Override
    public void update(User user) {
        userDao.updateById(user);
    }

    @Override
    public void del(int id) {
        userDao.deleteById(id);
    }

    @Override
    public void add(User user) {
        userDao.insert(user);
    }
}
